package com.bulemobi.activity.ac_userCentre_Setting;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.bulemobi.activity.ac_user_centre.Ac_AboutUs;
import com.bulemobi.adapter.SettingAdapter;
import com.bulemobi.net.tsz.afinal.annotation.view.ViewInject;
import com.bulemobi.view.BaseActivity;
import com.bulemobi.view.titleView.ActionBarView;
import com.jsyh.hcb.R;

import java.util.ArrayList;

/**
 * Created by zengys on 2014/9/22.
 * 设置
 */
public class Ac_Setting_up extends BaseActivity implements View.OnClickListener {
    @ViewInject(id = R.id.actionBar)
    ActionBarView actionBarView;
    @ViewInject(id = R.id.lv_seting_up)
    ListView lv_seting_up;
    private SettingAdapter adapter;
    private ArrayList<String> settingList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_seting_up);
        initView();
    }

    private void initView() {
        actionBarView.title.setText(getResources().getString(R.string.setting_up_title));
        //初始化list
        settingList = new ArrayList<String>();
        for (int i = 0; i < getResources().getStringArray(R.array.setting_array).length; i++) {
            settingList.add(getResources().getStringArray(R.array.setting_array)[i]);
        }
        adapter = new SettingAdapter(this, settingList);
        lv_seting_up.setAdapter(adapter);
        lv_seting_up.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    //修改登陆密码
                    openActivity(Ac_Change_LoginPw.class);
                } else if (position == 1) {
                    //关闭手势密码
                    SharedPreferences sharedPreferences = getSharedPreferences("LOCK",0);
                    SharedPreferences.Editor editor = sharedPreferences.edit();
                    if(sharedPreferences.getString("lock","0").equals("open")){
                        editor.putString("lock","close");
                    }
                    editor.commit();
                    showToastShort("关闭成功");
                } else if (position == 2) {
                    //修改交易密码
                    openActivity(Ac_Change_Trade_Password.class);
                } else if (position == 3) {
                    //版本更新
                } else if (position == 4) {
                    //关于我们
                    openActivity(Ac_AboutUs.class);
                } else {
                    //应用分享
                }
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {


        }
    }
}
